<?php
if(!defined('READY2BLUE'))
	exit;
class CommandLine
{
	public $CommandString;
	public $Command;
	public $Params=array();
	public $BoolParams=array();
	public function CommandLine($commandString)
	{
		$this->CommandString=$commandString;
	}
	public function Parse()
	{
		$params=explode(' ',$this->CommandString);
		if(count($params)==0)
			return false;
		$this->Command=strtolower($params[0]);
		if($this->Command=='exit')
		{
			$this->Command='quit';
		}
		array_shift($params);
		foreach ($params as $param)
		{
			if($param==' ')
				continue;
			if(substr($param,0,1)=='-')
				$this->BoolParams[]=substr($param,1);
			else
				$this->Params[]=$param;
		}
		return true;
	}
	
	public function GetCommand()
	{
		return $this->Command;
	}
	public function GetParams()
	{
		return $this->Params;
	}
	public function GetBoolParams()
	{
		return $this->BoolParams;
	}
	public function GetBoolParam($param)
	{
		return in_array($param,$this->BoolParams);
	}
	
	public function GetParam($param)
	{
		if(array_key_exists($param,$this->Params))
			return $this->Params[$param];
		return null;
	}
	
}
?>